<template>
    <div>
        <v-toolbar dark color="primary" style="box-shadow:none">
            <v-icon @click="$router.back(-1)">keyboard_arrow_left</v-icon>
            <v-toolbar-title style="margin:0">团购详情</v-toolbar-title>
        </v-toolbar>
        <v-carousel style="height:250px" hide-delimiters>
            <v-carousel-item
            v-for="(item,i) in purchase.purchasePics"
            :key="i"
            :src="item.src"
            ></v-carousel-item>
        </v-carousel>
        <v-container style="margin-bottom:48px">
        <v-layout row wrap>
            <v-flex xs12 style="margin-bottom:10px">
                <span style="font-size:20px"><b>{{purchase.purchaseName}}</b></span>
                <span style="float:right;font-size:20px;color:#515151"><b>{{purchase.purchasePrice}}元</b></span>
            </v-flex>
            <v-flex xs12>
                <p style="font-size:15px">{{purchase.purchaseDetail}}</p>
            </v-flex>
            <v-flex xs12>
                <v-icon small light>place</v-icon><span>{{purchase.communityName}}</span>
                <span style="float:right">{{purchase.createdBy}}发起</span>
            </v-flex>
            <v-flex text-xs-center justify-center align-center xs12>
                <div style="border:2px solid green;border-radius:10px;margin:auto;display:inline-block;padding:20px;margin-top:30px">
                    <h3>已有{{purchase.participant}}人参加团购</h3>
                    <h3>还差{{purchase.people-purchase.participant}}人</h3>
                </div>
            </v-flex>
        </v-layout>
        </v-container>
        <div flat style="z-index:1;position:fixed;bottom:0;width:100%">
            <v-layout justify-center align-center style="background:#eeeeee">
            <v-flex text-xs-center style="background:#4caf50">
                <v-btn color="white" flat value="person" style="width:100%;" @click="join" :disabled="hasJoin">
                    <span>确认参加</span>
                </v-btn>
            </v-flex>
            </v-layout>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return {
            purchase:{
                purchaseName:'洗衣机',
                purchaseDetail:'大家一起买洗衣机洗衣机哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈红红火火恍恍惚惚'+
                '大家一起买洗衣机洗衣机哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈红红火火恍恍惚惚'+
                '大家一起买洗衣机洗衣机哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈红红火火恍恍惚惚'+
                '大家一起买洗衣机洗衣机哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈红红火火恍恍惚惚',
                communityName:'国际软件学院',
                createdBy:'张三',
                participant:2,
                people:200,
                price: 200,
                purchasePics: [
                    {src:'http://ppt.downhot.com/d/file/p/2014/08/05/cb5322240543dabe9401fd166a1a6cfc.png'},
                    {src:'http://img1.3lian.com/2015/w1/76/d/81.jpg'},
                    {src:'http://pic1.16pic.com/00/11/69/16pic_1169706_b.jpg'}
                ],
            },
            purchaseContent:['purchaseName','purchaseDetail','communityName','createdBy','purchasePrice'],//max people namber and participate
            hasJoin:false
        }
    },
    methods:{
        join(){
            this.purchase.participant--;
            this.hasJoin=true
            // this.$axios({
            //     method:'get',
            //     url:'/groupPurchase',
            // }).then(
            //     function(response){
            //         var res=response.parseJSON()
            //         this.anouncements=res['data']
            //     }
            // ).catch({
            //     function(response){
            //         console.log(response)
            //     }
            // })
        },
        getDetail(){
            this.$axios({
                method:'get',
                url:'/getPurchaseDetail/'+this.$route.params.purchaseID,
                headers:{

                }
            }).then(
                function(response){
                    var res=response.parseJSON()
                    this.anouncements=res['data']
                }
            ).catch({
                function(response){
                    console.log(response)
                }
            })
        },
        setContent(res){
            for(var i in this.purchaseContent){
                this.purchase[this.purchaseContent[i]]=row[this.dishContent[i]]
            }
            var attachments=res['attachments']
            for(var i in attachments){
                this.purchase['purchasePics'].push(attachments[i]['attachmentUrl'])
            }
        }
    }
}
</script>

